<template>
<div class="flow-container">
  <div class="center-home-layout">
    <div class="center-sidebar">
      <index />
    </div>
    <!-- 侧边栏 -->
    <!-- 主要内容区域 -->
    <main class="center-main">
      <div class="content-wrapper">
        <router-view />
      </div>
    </main>
  </div>
  </div>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Setting, ChatDotRound, Files } from '@element-plus/icons-vue'
import index from './index.vue'

const route = useRoute()
const router = useRouter()
const activeMenu = ref('forum-manager')

// 监听路由变化，更新活跃菜单
watch(
  () => route.name,
  (name) => {
    if (name === 'ForumManager') {
      activeMenu.value = 'forum-manager'
    } else if (name === 'ResourcesManager') {
      activeMenu.value = 'resources-manager'
    }
  },
  { immediate: true }
)

// 处理菜单选择
const handleMenuSelect = (key: string) => {
  if (key === 'forum-manager') {
    router.push({ name: 'ForumManager' })
  } else if (key === 'resources-manager') {
    router.push({ name: 'ResourcesManager' })
  }
}
</script>

<style scoped>
.center-home-layout {
  display: flex;
  min-height: calc(100vh - 80px);
  background: transparent;
  gap: 15px;
  padding: 24px;
  width: 100%;
  max-width: 1500px; /* 更适合主流屏幕 */
  margin: 0 auto;
  box-sizing: border-box;
}

.center-sidebar {
  width: 260px;
  height: 100%;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  
}

.sidebar-header {
  padding: 32px 24px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--primary-purple), var(--primary-blue));
  color: white;
  margin: 0;
}

.sidebar-icon {
  font-size: 24px;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  flex: 1;
  background: transparent !important;
  border-right: none !important;
  padding: 16px 0;
}

:deep(.el-menu-item) {
  color: var(--text-primary);
  border-radius: var(--radius-md);
  margin: 8px 16px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 48px;
  line-height: 48px;
}

:deep(.el-menu-item:hover) {
  background: var(--light-purple);
  color: var(--primary-blue);
  box-shadow: var(--shadow-sm);
  transform: translateX(4px) scale(1.02);
}

:deep(.el-menu-item.is-active) {
  background: var(--gradient-purple);
  color: #ffffff;
  font-weight: 600;
  box-shadow: var(--shadow-purple);
  transform: scale(1.02);
}

:deep(.el-menu-item .el-icon) {
  margin-right: 12px;
  font-size: 18px;
}

.center-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.content-wrapper {
  flex: 1;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 400px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .center-home-layout {
    max-width: 98vw;
    padding: 12px;
  }
  .center-sidebar {
    width: 200px;
  }
}

@media (max-width: 900px) {
  .center-home-layout {
    flex-direction: column;
    gap: 12px;
    padding: 8px;
  }
  .center-sidebar {
    width: 100%;
    min-width: 0;
    margin-bottom: 8px;
  }
  .center-main {
    width: 100%;
  }
}

/* 滚动条样式 */
:deep(.content-wrapper)::-webkit-scrollbar {
  width: 6px;
}

:deep(.content-wrapper)::-webkit-scrollbar-track {
  background: var(--bg-light);
  border-radius: 3px;
}

:deep(.content-wrapper)::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
  transition: background 0.3s ease;
}

:deep(.content-wrapper)::-webkit-scrollbar-thumb:hover {
  background: var(--primary-purple);
}
</style>